﻿using System;
using System.Windows.Forms;
using Server.Manager;
using Server.Network;
using Server.Maps;

namespace The_World_Server
{
    static class Program
    {
        public static frmServer server;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            int time1 = Environment.TickCount;
            int time2 = 0;

            server = new frmServer();
            server.Show();
            server.TextAdd("Loading Maps");
            MapManager.Instance.LoadMap();
            server.TextAdd("Loading Entities");
            DataManager.Instance.ReadEntityData();
            server.TextAdd("Loading Armor");
            DataManager.Instance.ReadArmorData();
            server.TextAdd("Loading Weapons");
            DataManager.Instance.ReadWeaponData();
            server.TextAdd("Loading Shields");
            DataManager.Instance.ReadShieldData();
            server.TextAdd("Loading Key");
            DataManager.Instance.ReadKeyData();
            server.TextAdd("Loading Chests");
            DataManager.Instance.ReadChestData();
            server.TextAdd("Loading Skills");
            DataManager.Instance.ReadSkillData();
            server.TextAdd("Loading Sockets...");
            NetworkManager.Instance.InitServer();
            Loop.Instance.isServerRunning = true;
            Application.Idle += new EventHandler(Loop.Instance.ServerLoop);

            time2 = Environment.TickCount;
            server.TextAdd("Server initialization complete. Server loaded in " + (time2 - time1) + "ms.");

            Application.Run(server);
        }
    }
}
